#include "ServerUdp.hpp"
#include "User.hpp"
#include "InetAdrr.hpp"

//./server_udp port
int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        std::cerr << "Use error, Please use on ./server_udp port" << std::endl;
        DIE(1);
    }

    uint16_t port =std::stoi(argv[1]);
    std::shared_ptr<UserManager> um = std::make_shared<UserManager>();
    std::shared_ptr<Server_Udp> server_ptr = std::make_shared<Server_Udp>(port);
    server_ptr->InitSocket();
    server_ptr->Rgisterservice([um](InetAddr& in){um->AddUser(in);},
                                [um](int shockfd,const std::string & message){um->route(shockfd,message);});

    server_ptr->Start();
    return 0;
}